home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / unix / utimes.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  971b  |  53 lines

  1.  
  2. /*
  3.  *  UNIX/UTIMES.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  *
  9.  */
  10.  
  11. #include <time.h>
  12. #include <dos/dos.h>
  13. #include <clib/dos_protos.h>
  14.  
  15. #ifndef UnixToAmigaPath
  16. #define UnixToAmigaPath(path)   path
  17. #endif
  18.  
  19. int utime(char *, time_t *);
  20. int utimes(char *, struct timeval *);
  21.  
  22. int
  23. utime(path, times)
  24. char *path;
  25. time_t *times;
  26. {
  27.     struct timeval ts[2];
  28.  
  29.     ts[0].tv_secs = times[0];
  30.     ts[0].tv_micro= 0;
  31.     ts[1].tv_secs = times[1];
  32.     ts[1].tv_micro= 0;
  33.     return(utimes(path, ts));
  34. }
  35.  
  36. int
  37. utimes(path, times)
  38. char *path;
  39. struct timeval *times;
  40. {
  41.     long v[3];
  42.     time_t t = times[1].tv_secs;
  43.  
  44.     v[0] = (unsigned long)t / 86400;        /*  day */
  45.     v[1] = ((unsigned long)t / 60) % 1440;
  46.     v[2] = ((unsigned long)t % 60) * 50;
  47.  
  48.     if (SetFileDate(UnixToAmigaPath(path), (struct DateStamp *)v))
  49.     return(0);
  50.     return(-1);
  51. }
  52.  
  53.